package com.dlut.java2;

import java.util.Arrays;
import java.util.Scanner;


/**
 * @Author: LiuHeng
 * @Description:
 * @Date: 2022-09-07 15:31
 */
public class T0907_ShunFeng {

    /**
     * n种试卷，出m套试题
     * @param args
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        if(n<m){
            System.out.println(0);
        }
        Arrays.sort(arr);
        long count = 0;
        while (arr[n-m] > 0){
            int temp = (arr[n-m] + 1) / 2;
            count += temp;
            for (int i = n-1; i >= n-m; i--) {
                arr[i] -= temp;
            }
            //Arrays.sort(arr);
            merge(arr, n-m);
        }
        System.out.println(count);
    }
    public static void merge(int[] arr, int k){
        int n = arr.length;
        int[] num = new int[n];
        int k1=0,k2=k,k3=0;
        while (k1<k && k2 <n){
            if (arr[k1] <arr[k2]){
                num[k3++] = arr[k1++];
            }else{
                num[k3++] = arr[k2++];
            }
        }
        while (k1 < k){
            num[k3++] = arr[k1++];
        }
        while (k2 < n){
            num[k3++] = arr[k2++];
        }
        System.arraycopy(num,0,arr,0,n);
    }
}
